<?php
// +----------------------------------------------------------------------
// | CLTPHP.Pro [会员管理]
// +----------------------------------------------------------------------
// | Copyright (c) 2019-2029 https://www.cltphp.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( https://www.cltphp.com/detail-140.html )
// +----------------------------------------------------------------------
// | Author: chichu <1109305987@qq.com>
// +----------------------------------------------------------------------

namespace app\admin\controller;

use app\common\model\UserLevel;
use app\common\model\Users as M;
use think\facade\Request;
use think\facade\Db;
use think\facade\View;

class Bill extends Base
{

    //账单列表
    public function index()
    {
        if (Request::isAjax()) {
            //分页
            $page = input('page') ? input('page') : 1;
            $pageSize = input('limit') ? input('limit') : config('pageSize');
            $page = ['list_rows' => $pageSize, 'page' => $page];

            $key = input('post.key');
            $where = [];
            if (!empty($key)) {
                $where[] = ['mobile|username', 'like', '%' . $key . '%'];
            }
            //排序
            $sort_order = input('sort_order') ? input('sort_order') : 'desc';
            $order = input('sort_order') ? [input('sort_by') => $sort_order] : ['create_time' => $sort_order];

            $list = M::getList($where, $page, $order)->toArray();

            return ['code' => 0, 'msg' => '获取成功!', 'data' => $list['data'], 'count' => $list['total']];
        } else {
            return view();
        }
    }

}